def day_of_year(year, month, day):
    """计算给定日期是一年中的第几天"""
    # 每个月的天数
    month_days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
    
    # 判断是否为闰年
    if (year % 400 == 0) or (year % 4 == 0 and year % 100 != 0):
        month_days[1] = 29  # 如果是闰年，二月天数为29
    
    # 计算天数
    total_days = sum(month_days[:month - 1]) + day  # 计算总天数
    return total_days

# 测试函数
print(day_of_year(2024, 4, 29))  # 输出: 120
print(day_of_year(2021, 2, 28))  # 输出: 59
print(day_of_year(2020, 2, 29))  # 输出: 60
